import CryptoJS from 'crypto-js';

const secretKey = 'N5bDHnKn48IL66XqiFrqLxix7pajayud4sS7';

export function encrypt(data: string) {
  if (!data) {
    return data;
  }

  const encrypted = CryptoJS.AES.encrypt(data, secretKey).toString();
  return encrypted;
}

export function decrypt(data: string) {
  if (!data) {
    return data;
  }

  const bytes = CryptoJS.AES.decrypt(data, secretKey);
	const originalText = bytes.toString(CryptoJS.enc.Utf8);
  return originalText;
}

export function md5(str: string) {
  return CryptoJS.MD5(str).toString();
}
